<?php 
function list_jadwal_check_up(){
	$ddate= isset($_POST['tanggal']) ? $_POST['tanggal'] : date('d-m-Y');
	 
	list($dd,$mm,$y) = explode('-',$ddate);
	my_set_file_js(
		array( 
			'components/system/js/calendar/calendarDateInput.js'
		)
	);
	$header = array(
		'NIK'=>array('style'=>'text-align:center;border-bottom:2px solid;width:10%'),  
		'Nama'=>array('style'=>'text-align:center;border-bottom:2px solid;width:25%'),  
		'Jabatan'=>array('style'=>'text-align:center;border-bottom:2px solid;width:35%'),  
		'HUT'=>array('style'=>'text-align:center;border-bottom:2px solid;width:15%'),  
		'TMB'=>array('style'=>'text-align:center;border-bottom:2px solid;width:15%'),  
	//	' '=>array('style'=>'border-bottom:2px solid;width:5%'), 
	);
	$dd = (int)$dd;
	$mm = (int)$mm;
	$query = " SELECT a.karyawan_id, EXTRACT(MONTH from b.tmb) as bulan, 
		EXTRACT(DAY from b.tmb) as tgl 
		FROM karyawan a
		LEFT JOIN kekaryawanan b ON b.karyawan_id=a.karyawan_id 
		WHERE EXTRACT(MONTH from b.tmb)='{$mm}' 
		AND EXTRACT(DAY from b.tmb)='1' 
		AND a.karyawan_id NOT IN (select karyawan_id FROM karyawan_disable)
		AND a.karyawan_id NOT IN (select karyawan_id FROM pemberhentian) 
		";
		//  print($query);exit;
	$result = my_query($query);
	$total_records = my_num_rows($result );
	$scroll_page =5;  
	$per_page =15;  
	$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1 ; 
	if($current_page < 1){
		$current_page = 1;
	}		 
	$pager_url  ="index.php?com=validasi&task={$_GET['task']}&field={$_GET['field']}&key={$_GET['key']}&page=";	 
	$inactive_page_tag = 'style="padding:4px;background-color:#BBBBBB"';  
	$previous_page_text = ' Mundur '; 
	$next_page_text = ' Maju ';  
	$first_page_text = ' Awal '; 
	$last_page_text = ' Akhir ';
	
	$kgPagerOBJ = new kgPager();
	$kgPagerOBJ->pager_set(
		$pager_url, 
		$total_records, 
		$scroll_page, 
		$per_page, 
		$current_page, 
		$inactive_page_tag, 
		$previous_page_text, 
		$next_page_text, 
		$first_page_text, 
		$last_page_text ,$pager_url_last); 
				
	$result = my_query($query ." LIMIT ".$kgPagerOBJ->start.", ".$kgPagerOBJ->per_page); 	
	$row = array(); 
	$i = ($current_page  - 1 ) * 15; 
	while($ey = my_fetch_array($result)){
		$karyawan = loaddata_karyawan($ey['karyawan_id']);
 
		if(empty($karyawan['gelar'])){
			$nama_karyawan=ucfirst($karyawan['nama']) ;
		}else{
			$nama_karyawan=trim(ucfirst($karyawan['nama'])).", ".$karyawan['gelar'] ;
		}		
		$jabatan = my_get_data_by_id('jabatan','jabatan_id' , $karyawan['jabatan_id']); 
		$hut = mktime(0, 0, 0, $ey['bulan'], $ey['tgl'], date('Y', time()));

		$row[] = array(
			'NIK'=>position_text_align ($karyawan['nik'] ,'center'),    
			'Nama'=>$nama_karyawan ,
			'Jabatan'=>$jabatan['nama_jabatan']  ,  
			'HUT'=>date( 'd - m - Y' , $hut ),
			'TMB'=>date( 'd - m - Y' , strtotime($karyawan['tmb']) ),   
		); 
	}
	$view  = form_header( "..." , "..."  );
	$view .= form_field_display( '<span class="label_form"> '.returnDate(date("N"), "day") . ", " . date("j") . " " . returnDate(date("n"), "month") . " " . date("Y").'</span>'   , "<b>Tanggal Hari Ini</b>"    ); 
	$forms = array(
				'name'=>'tanggal',
				'value'=>(isset($_POST['tanggal'])? $_POST['tanggal'] :   date('d-m-Y') ),
				'id'=>'tanggal'
			);
	$view .= form_field_display( '<span class="label_form"> <form method="POST"><input type="hidden" name="com" value="jadwal_check_up" /><table border="0"><tr><td>'.form_calendar($forms).' </td><td><input type="submit" value=" GO " /></td></tr></table></form></span>'   , "<b>Browse waktu</b>"    ); 
	$datas = table_rows($row);
	$menuontop = array(  
		'Cetak' => array('onclick'=>'javascript:window.open(\'index.php?com=report&task=voucher_check_up\',\'mywin\',\'left=20,top=20,width=800,height=600,toolbar=0,resizable=0\');')
	);	
	$printmenu = additional_menu_on_list( $menuontop , '');
	$paging = $kgPagerOBJ ->showPaging();	
	return  $view.$printmenu.table_builder($header , $datas ,  6 , false   );
}
